from django.conf import settings
from django.urls import include, path
from . import views
from rest_framework import routers
from django.conf.urls.static import static
from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
)
from .views import (
    ChangePhoneView,
    ChefPendingSlotsCountView,
    ChefRecentPendingSlotsView,
    ChefStatusUpdateView,
    ChefsAvatarUploadView,
    SMSCodeView,
    SMSLoginView,
    SendChangePhoneSMSView,
    VdjChefAuthDetailView,
    VdjChefAuthListView,
    WechatLoginView,
    VerificationImageView,
    SubmitVerificationView,
    VerificationStatusView,
    VdjChefAuthVerifyView,
    chef_menu_view  
)
from apps.menu.views import ChefMenuViewSet


app_name = 'chefs'


consumer_router = routers.DefaultRouter()
consumer_router.register(r'(?P<chef_id>\d+)/menu', ChefMenuViewSet, basename='chef-menu')


# 消费端相关 URL
chef_urls = [
    path('chefslist/', views.ChefListView.as_view(), name='chef-list'),
    path('conschefs/<int:id>/', views.ChefDetailView.as_view(), name='chef-detail'),
    path('chefs/<int:chef_id>/reviews/', views.ChefReviewCreateView.as_view(), name='chef-review-create'),
    path('reviews/<int:id>/', views.ChefReviewUpdateDeleteView.as_view(), name='chef-review-detail'),
    path('chefs/<int:chef_id>/time-slots/', views.ChefTimeSlotView.as_view(), name='chef-time-slots'),
    path('orders/', views.OrderCreateView.as_view(), name='order-create'),
    path('ordersdetail/<int:id>/', views.OrderDetailView.as_view(), name='order-detail'),
    path('user/orders/', views.UserOrderListView.as_view(), name='user-order-list'),
    path('chef/orders/', views.ChefOrderListView.as_view(), name='chef-order-list'),
    path('chefs/<int:chef_id>/categories/', views.ChefCategoryListView.as_view(), name='chef-category-list'),
    path('chefs/<int:chef_id>/dishes/', views.ChefDishListView.as_view(), name='chef-dish-list'),
    #消费端获取客户端菜品列表
    path('', include(consumer_router.urls)),
    path('consumer/chefs/<int:chef_id>/menu/',chef_menu_view,name='chef-full-menu'),
]

# 厨师端相关 URL
chef_client_urls = [
    path('profile/', views.ChefProfileView.as_view(), name='chef-profile'),
    path('profile/background/', views.ChefBackgroundUploadView.as_view(), name='chef-background-upload'),
    path('sms-code/', SMSCodeView.as_view(), name='sms-code'),
    path('login/sms/', SMSLoginView.as_view(), name='sms-login'),
    path('login/wechat/', WechatLoginView.as_view(), name='wechat-login'),
    path('sms/change-phone/', SendChangePhoneSMSView.as_view(), name='send-change-phone-sms'),
    path('change-phone/', ChangePhoneView.as_view(), name='change-phone'),
    path('avatar/upload/', ChefsAvatarUploadView.as_view(), name='avatar-upload'),
    path('upload-verification-image/', VerificationImageView.as_view(), name='upload-verification-image'),
    path('submit-verification/', SubmitVerificationView.as_view(), name='submit-verification'),
    path('verification-status/', VerificationStatusView.as_view(), name='verification-status'),
    path('status/', ChefStatusUpdateView.as_view(), name='chef-status-update'),
    # 轮询用接口 - 返回待处理档期数量
    path('pending-slots/count/', ChefPendingSlotsCountView.as_view(), name='chef-pending-slots-count'),
    # 详情接口 - 可用于获取具体新订单信息
    path('pending-slots/recent/', ChefRecentPendingSlotsView.as_view(), name='chef-recent-pending-slots'),
    path('sync-subscribe-status/', views.sync_subscribe_status, name='sync-subscribe-status'),

]

# 厨师端后台相关 URL
chef_admin_urls = [
    path('vdj/chefs/', views.VdjChefListView.as_view(), name='vdj-chef-list'),
    path('vdj/chefs/<int:id>/', views.VdjChefDetailView.as_view(), name='vdj-chef-detail'),
    path('vdj/chefs/<int:chef_id>/reviews/', views.VdjChefReviewCreateView.as_view(), name='vdj-chef-review-create'),
    path('vdj/reviews/<int:id>/', views.VdjChefReviewUpdateDeleteView.as_view(), name='vdj-chef-review-detail'),
    path('vdj/chefs/<int:chef_id>/categories/', views.VdjChefCategoryListView.as_view(), name='vdj-chef-category-list'),
    path('vdj/chefs/<int:chef_id>/dishes/', views.VdjChefDishListView.as_view(), name='vdj-chef-dish-list'),
    path('vdj/profile/', views.VdjChefProfileView.as_view(), name='vdj-chef-profile'),
    path('vdj/profile/background/', views.VdjChefBackgroundUploadView.as_view(), name='vdj-chef-background-upload'),
    path('vdj/sms-code/', views.VdjSMSCodeView.as_view(), name='vdj-sms-code'),
    path('vdj/login/sms/', views.VdjSMSLoginView.as_view(), name='vdj-sms-login'),
    path('vdj/login/wechat/', views.VdjWechatLoginView.as_view(), name='vdj-wechat-login'),
    path('vdj/sms/change-phone/', views.VdjSendChangePhoneSMSView.as_view(), name='vdj-send-change-phone-sms'),
    path('vdj/change-phone/', views.VdjChangePhoneView.as_view(), name='vdj-change-phone'),
    path('vdj/upload-verification-image/', views.VdjVerificationImageView.as_view(), name='vdj-upload-verification-image'),
    path('vdj/submit-verification/', views.VdjSubmitVerificationView.as_view(), name='vdj-submit-verification'),
    path('vdj/verification-status/', views.VdjVerificationStatusView.as_view(), name='vdj-verification-status'),
]

# 厨师身份认证后台管理相关 URL
chef_auth_admin_urls = [
    path('vdj-chefs-auth/', VdjChefAuthListView.as_view(), name='vdj-chefs-auth-list'),
    path('vdj-chefs-auth/<int:id>/', VdjChefAuthDetailView.as_view(), name='vdj-chefs-auth-detail'),
    path('vdj-chefs-auth/<int:pk>/verify/', VdjChefAuthVerifyView.as_view(), name='vdj-chefs-auth-verify'),
    path('upload-id-card/', views.IdCardUploadView.as_view(), name='id-card-upload'),

]

urlpatterns = chef_urls + chef_client_urls + chef_admin_urls + chef_auth_admin_urls

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)